<template>

</template>

<script type="text/ecmascript-6">
  import workerRouter from '../router/src/workingTable'

  export default {
    created () {
      this.$axios.get('/api/post/workplace/list')
        .then(res => {
          if (res.data.meta.success) {
            // 170010
            const userWorker = this.$store.state.user.info.workplaceId
            // 用户数据返回了工作台id
            if (userWorker) {
              // 获取权限ID
              const resData = res.data.data.map(item => {
                const curRouter = workerRouter.find(inItem => inItem.path === item.templateUrl)

                return {
                  ...item,
                  authId: (curRouter && curRouter.meta.id) || ''
                }
              })

              const find = resData.find(item => item.id === userWorker)

              if (find && (find.authId === 'notAuth' || this.findAuth(find.authId))) {
                this.$router.replace(find.templateUrl)
              } else {
                this.$router.replace('/MessageList')
              }
            } else {
              this.$router.replace('/MessageList')
            }
          }
        })
    }
  }
</script>


